package com.zksk.gateway;

import cn.hutool.core.util.StrUtil;
import org.springframework.boot.SpringApplication;
import org.springframework.boot.autoconfigure.SpringBootApplication;
import org.springframework.boot.autoconfigure.jdbc.DataSourceAutoConfiguration;
import org.springframework.boot.builder.SpringApplicationBuilder;
import org.springframework.boot.web.servlet.support.SpringBootServletInitializer;
import org.springframework.context.ConfigurableApplicationContext;
import org.springframework.core.env.Environment;

import java.net.InetAddress;
import java.net.UnknownHostException;

/**
 * 网关启动程序
 * 
 * @author zksk
 */
@SpringBootApplication(exclude = {DataSourceAutoConfiguration.class })
public class ZkskGatewayApplication  extends SpringBootServletInitializer
{
    @Override
    protected SpringApplicationBuilder configure(SpringApplicationBuilder builder) {
        return builder.sources(ZkskGatewayApplication.class);
    }
    public static void main(String[] args) throws UnknownHostException {
        SpringApplication application = new SpringApplication(ZkskGatewayApplication.class);
        ConfigurableApplicationContext run = application.run(args);
        Environment env = run.getEnvironment();
        String ip = InetAddress.getLocalHost().getHostAddress();
        String port = env.getProperty("server.port");
        String path = env.getProperty("server.servlet.context-path");
        System.out.println("(♥◠‿◠)ﾉﾞ  网关服务启动成功   ლ(´ڡ`ლ)ﾞ ");
        System.out.println("\n----------------------------------------------------------\n\t" +
                "Service Swagger文档地址: \thttp://" + ip + ":" + port + (StrUtil.isBlank(path)?"":path) + "/doc.html\n" +
                "----------------------------------------------------------");
    }
}
